package com.zmx.piglearn.service

import android.app.Service
import android.content.Intent
import android.os.IBinder
import com.zmx.piglearn.aidl.IPerson

class AidlService : Service() {

    private val binder = PersonQueryBinder()
    private val names = arrayOf("B神", "艹神", "基神", "J神", "翔神")

    private fun query(num: Int): String {
        if (num in 1..5) {
            return names[num-1]
        }
        return ""
    }

    override fun onBind(intent: Intent?): IBinder? {
        return binder
    }

    private inner class PersonQueryBinder : IPerson.Stub() {
        override fun queryPerson(num: Int): String {
            return query(num)
        }
    }
}